<template>
	<view class="goods_item">
		<!-- 左侧盒子 -->
		<view class="goods_item_left">
			<radio :checked="goods.goods_state" color="#C00000" v-if="showRadio" @click="radiocheckHandler"></radio>
			<image :src="goods.goods_small_logo" class="goods_pic"></image>
		</view>
		<!-- 右侧盒子 -->
		<view class="goods_item_right">
			<view class="goods_name">{{goods.goods_name}}</view>
			<view class="goods_info-box">
				<text class="goods_price">￥{{goods.goods_price | toFixed}}</text>
				<uni-number-box :min="1" :value="goods.goods_count" v-if="showNum" @change="numChangeHandler"></uni-number-box>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		name:"my-goods",
		props:{
			goods:{
				type:Object,
				default:{}
			},
			showRadio:{
				type:Boolean,
				//默认不显示Radio
				default:false
			},
			showNum:{
				type:Boolean,
				//默认不显示
				default:false
			}
		},
		data() {
			return {
				
			};
		},
		filters:{
			toFixed(num){
				return Number(num).toFixed(2)
			}
		},
		methods:{
			radiocheckHandler(){
				
				this.$emit('radio_change',{
					goods_id:this.goods.goods_id,
					goods_state: !this.goods.goods_state
				})
			},
			numChangeHandler(val){
				this.$emit('num_change',{
					goods_id:this.goods.goods_id,
					goods_count: +val
				})
			}
		}
		
	}
</script>

<style lang="scss">
.goods_item{
	display: flex;
	flex: 1;
	padding:10px 5px;
	border-bottom: 1px solid #f0f0f0;
	.goods_item_left{		
		margin-right: 5px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.goods_pic{
			width: 100px;
			height: 100px;
			display: block;
		}
		
	}
	.goods_item_right{
		display: flex;
		flex:1;
		flex-direction: column;
		justify-content: space-between;
		.goods_name{
			font-size: 13px;
		}
		.goods_info-box{
			display: flex;
			justify-content: space-between;
			align-items: center; 
			.goods_price{
				font-size: 17;
				color: #C00000;
			}
		}
		
	}
}
</style>